#include <iostream>
#include <vector>
using namespace std;

class Solution {
private:
    bool dfs(bool* visited,vector<vector<int>>& graph,int size,int start,int target)
    {
        for(int i = 0;i < size;++i)
        {
            if(!visited[i])
            {
                if(graph[i][0] == start && graph[i][1] == target) return true;
            }
            visited[i] = true;
            if(graph[i][1] == target && dfs(visited,graph,size,start,graph[i][0]))
            {
                return true;
            }
            visited[i] = false;
        }
        return false;
    }
public:
    bool findWhetherExistsPath(int n, vector<vector<int>>& graph, int start, int target) {
        int size = graph.size();
        bool* visited;
        memset(visited,0,sizeof(bool)*size);
        return dfs(visited,graph,size,start,target);
    }
};

int main()
{
    return 0;
}